{% extends "base_fullpage.html" %}

{% set is_new = storage_unit is none %}

{% block subtitle %}{% if is_new %}New storage unit{% else %}Update storage unit {{ storage_unit.name }} {% endif %}{% endblock %}

{% block content %}

<h2>{% if is_new %}New storage unit{% else %}Update storage unit {{ storage_unit.name }} {% endif %}</h2>

<form action="/storage_unit/update" method="POST">
  <label for="name">Name</label>
  <input id="name" type="text" name="name" value="{{ storage_unit.name }}" maxlength="100"/>
  <br />

  <label for="description">Description</label>
  <textarea id="description" name="description">{{ storage_unit.description }}</textarea>
  <br />

  <label for="location">Location</label>
  <textarea id="location" name="location">{{ storage_unit.location }}</textarea>
  <br />

  <label for="slots">Slots</label>
  <textarea id="slots" name="slots" rows="{{ 2+storage_unit.slots|count }}">{{ storage_unit.slots|join('\n') }}</textarea> <br/>
  <span>One slot per line</span>
  <br />

  {% if is_new %}
  <input type="submit" name="action" value="Create" />
  <input type="submit" name="action" value="Cancel" />
  {% else %}
  <input type="hidden" name="key" value="{{ storage_unit.key.urlsafe() }}" />
  <input type="submit" name="action" value="Update" />
  <input type="submit" name="action" value="Cancel" />
  <input type="submit" name="action" value="Delete" />
  {% endif %}
</form>

{% endblock %}
